Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add synchronized to protect the map, to fix the bug: #76

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

zwChan
Copy link

@zwChan zwChan commented Nov 25, 2014

java.util.ConcurrentModificationException
at java.util.IdentityHashMap.remove(IdentityHashMap.java:729)
at com.ycache.danga.MemCached.SockIOPool.clearHostFromPool(Unknown Source)
at com.ycache.danga.MemCached.SockIOPool.createSocket(Unknown Source)
at com.ycache.danga.MemCached.SockIOPool.getConnection(Unknown Source)
at com.ycache.danga.MemCached.SockIOPool.getSock(Unknown Source)
at com.ycache.danga.MemCached.MemCachedClient.get(Unknown Source)
at com.ycache.danga.MemCached.MemCachedClient.get(Unknown Source)
at com.yihaodian.common.ycache.memcache.impl.BaseMemcacheProxy.get(Unknown Source)

java.util.ConcurrentModificationException
         at java.util.IdentityHashMap.remove(IdentityHashMap.java:729)
         at com.ycache.danga.MemCached.SockIOPool.clearHostFromPool(Unknown Source)
         at com.ycache.danga.MemCached.SockIOPool.createSocket(Unknown Source)
         at com.ycache.danga.MemCached.SockIOPool.getConnection(Unknown Source)
         at com.ycache.danga.MemCached.SockIOPool.getSock(Unknown Source)
         at com.ycache.danga.MemCached.MemCachedClient.get(Unknown Source)
         at com.ycache.danga.MemCached.MemCachedClient.get(Unknown Source)
         at com.yihaodian.common.ycache.memcache.impl.BaseMemcacheProxy.get(Unknown Source)
@zwChan
Copy link
Author

zwChan commented Nov 25, 2014

Hi,
We hit an exception 'ConcurrentModificationException' when some of the memcached is down. There are hundreds of threads in a client, after read the code, I think the 'clearHostFromPool' and 'addSocketToPool' are not thread-safe. So propose to add a synchronized for both function seems like a simple and effective solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant